<?php
require "../maths/tool_maths.php";
require "./tool_pear_graph.php";
require "../misc/tool_color.php";
require "../files/tool_files_dirs.php";
require "../array/tool_array.php";
$tool_graph=new tool_pear_graph();

$tool_graph->__set_width(500);
$tool_graph->__set_height(500);
$tool_graph->__add_title("");

$array_word = array(21665,27404,28740,33089,33801,35692);
$array_chunk = array(6387,8472,9044,11100,11714,12279);
$array_x = array_keys($array_word);


$tool_graph->__add_array_y($array_word);
$tool_graph->__add_array_x($array_x);
$tool_graph->__add_plot_title("nombre de mots");
$tool_graph->__add_plot_color("#FF0000");


$tool_graph->__add_array_y($array_chunk);
$tool_graph->__add_array_x($array_x);
$tool_graph->__add_plot_title("nombre de chunks");
$tool_graph->__add_plot_color("#00FF00");

$graph=$tool_graph->line_color00();

//$graph=$tool_graph->plot_line_regression2();

ob_start();
$graph->done();
$graph_svg=ob_get_contents();
Tool_files::file_write("./simple.svg",$graph_svg);
ob_clean();
die();
/*
$tool_graph->__add_array_y($array_y);
$tool_graph->__add_array_x($array_x);
 */

$coord=tool_maths::regression_lineaire_simple($array_x,$array_y);
$first_x=reset($array_x);
$last_x=end($array_x);
$first_y=$first_x*$coord["a"]+$coord["b"];
$last_y=$last_x*$coord["a"]+$coord["b"];

$tool_graph->__add_array_x(array($first_x,$last_x));
$tool_graph->__add_array_y(array($first_y,$last_y));


$tool_graph->__add_title("test");

//$graph=$tool_graph->plot03();

$graph=$tool_graph->line01();
//$graph=$tool_graph->plot_line_regression2();

ob_start();
$graph->done();
$graph_svg=ob_get_contents();
Tool_files::file_write("./out.svg",$graph_svg);
ob_clean();

?>
